// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
const $ = _.aggregate

// 云函数入口函数
/**
 * 
 * @param {我的偶像} event 
 * @param {*} context 
 */
exports.main = async (event, context) => {
  return await db.collection('ad_user_idol').aggregate()
  .lookup({
    from: 'ad_idol',
    localField: 'idol_id',
    foreignField:'_id',
    as: 'idol'
  })
  .match({
    hasdel: 0
  })
  .sort({
    create_time: -1
  })
  .skip(event.skip)
  .limit(event.limit)
  .replaceRoot({

  })
  .project({
    
  })
  .end()
}